﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO.WaiGaoQiao;
using System.Data;

namespace Model.WaiGaoQiao
{
    /// <summary>
    /// 劳保入库
    /// </summary>
    public class Work_StorageDetailedInfo
    {
        DataAccessWork_Storage DAS;
        /// <summary>
        /// 行记录
        /// </summary>
        private int rowcount = 0;
        public int _rowcount
        {
            get { return rowcount; }
        }
        /// <summary>
        /// 是否获得行记录
        /// </summary>
        /// <param name="isGetCount"></param>
        public Work_StorageDetailedInfo(bool isGetCount)
        {
            DAS = new DataAccessWork_Storage();
            if (isGetCount)
            {
                rowcount = DAS.GetCountStorageDetailed("");
            }

        }
        //构造函数
        public Work_StorageDetailedInfo() { }
        #region -----------------------劳保入库字段-------------------------
        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 入库日期
        /// </summary>
        public DateTime StorageDt { get; set; }

        /// <summary>
        /// 劳保物品id
        /// </summary>
        public int Article_ID { get; set; }
        /// <summary>
        /// 物品编号
        /// </summary>
        public string Article_NO { get; set; }
        /// <summary>
        /// 劳保物品规格
        /// </summary>
        public string Article_Unit { get; set; }
        /// <summary>
        /// 劳保物品颜色
        /// </summary>
        public string Article_Color { get; set; }
        /// <summary>
        /// 供应商
        /// </summary>
        public string Supplier { get; set; }
        /// <summary>
        /// 数量
        /// </summary>
        public int Count { get; set; }
        /// <summary>
        /// 操作人
        /// </summary>
        public string OperatorID { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 记录日期
        /// </summary>
        public DateTime RecordDateTime { get; set; }
        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderNo { get; set; }
        #endregion

        /// <summary>
        /// 生成批量输入编号
        /// </summary>
        /// <returns></returns>
        public virtual string BuliderOrderNo()
        {
            return DAS.GetStorageDetailedOrderNo();
        }
        /// <summary>
        /// 获取劳保物资入库数量
        /// </summary>
        /// <returns></returns>
        public int GetStorageDetailedCount(string Condition)
        {
            return DAS.GetCountStorageDetailed(Condition);
        }


        /// <summary>
        /// 保存劳保物资入库
        /// </summary>
        /// <param name="idab"></param>
        /// <returns></returns>
        public int SaveStorageDetailed(Work_StorageDetailedInfo sdiDetail)
        {
            object[] idpara = new object[] {sdiDetail.ID,sdiDetail.StorageDt, sdiDetail.Article_ID, sdiDetail.Article_NO,
                                            sdiDetail.Article_Unit, sdiDetail.Article_Color,sdiDetail.Supplier,sdiDetail.Count,sdiDetail.OperatorID,
                                            sdiDetail.Remark,sdiDetail.RecordDateTime,sdiDetail.OrderNo };
            return DAS.SaveStorageDetailed(idpara);
        }

        /// <summary>
        /// 获取劳保物资入库不分页
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public IList<Work_StorageDetailedInfo> GetAllStorageDetailed(string condition)
        {
            IList<Work_StorageDetailedInfo> Idalist = new List<Work_StorageDetailedInfo>();
            DataSet ds = DAS.GetAllStorageDetailed(condition);
            Work_StorageDetailedInfo ideinfo;
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ideinfo = new Work_StorageDetailedInfo()
                {
                    ID = Convert.ToInt32(item[0]),
                    StorageDt = Convert.ToDateTime(item[1]),
                    Article_ID = Convert.ToInt32(item[2]),
                    Article_NO = Convert.ToString(item[3]),
                    Article_Unit = item[4].ToString(),
                    Article_Color = item[5].ToString(),
                    Supplier = item[6].ToString(),
                    Count = Convert.ToInt32(item[7]),
                    OperatorID = item[8].ToString(),
                    Remark = item[9].ToString(),
                    RecordDateTime = Convert.ToDateTime(item[10]),
                    OrderNo = item[11].ToString()
                };
                Idalist.Add(ideinfo);
            }
            return Idalist;
        }


        /// <summary>
        /// 根据ID获取劳保物资入库实体类
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public Work_StorageDetailedInfo GetAllStorageDetailed(int Id)
        {
            DataRow item = DAS.GetAllStorageDetailed(" And id=" + Id).Tables[0].Rows[0];
            Work_StorageDetailedInfo ideinfo = new Work_StorageDetailedInfo()
            {
                ID = Convert.ToInt32(item[0]),
                StorageDt = Convert.ToDateTime(item[1]),
                Article_ID = Convert.ToInt32(item[2]),
                Article_NO = Convert.ToString(item[3]),
                Article_Unit = item[4].ToString(),
                Article_Color = item[5].ToString(),
                Supplier = item[6].ToString(),
                Count = Convert.ToInt32(item[7]),
                OperatorID = item[8].ToString(),
                Remark = item[9].ToString(),
                RecordDateTime = Convert.ToDateTime(item[10]),
                OrderNo = item[11].ToString()
            };
            return ideinfo;
        }


        /// <summary>
        /// 获取劳保物资入库分页
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public IList<Work_StorageDetailedInfo> GetAllStorageDetailed(string condition, int pagesize, int startindex)
        {
            IList<Work_StorageDetailedInfo> Idalist = new List<Work_StorageDetailedInfo>();
            DataSet ds = DAS.GetAllStorageDetailed(condition, pagesize, startindex);
            Work_StorageDetailedInfo ideinfo;
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                ideinfo = new Work_StorageDetailedInfo()
                {
                    ID = Convert.ToInt32(item[0]),
                    StorageDt = Convert.ToDateTime(item[1]),
                    Article_ID = Convert.ToInt32(item[2]),
                    Article_NO = Convert.ToString(item[3]),
                    Article_Unit = item[4].ToString(),
                    Article_Color = item[5].ToString(),
                    Supplier = item[6].ToString(),
                    Count = Convert.ToInt32(item[7]),
                    OperatorID = item[8].ToString(),
                    Remark = item[9].ToString(),
                    RecordDateTime = Convert.ToDateTime(item[10]),
                    OrderNo = item[11].ToString()
                };
                Idalist.Add(ideinfo);
            }
            return Idalist;
        }



        /// <summary>
        /// 删除劳保物资入库
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public int DeleteStorageDetailed(int Id)
        {
            return DAS.DeleteStorageDetailed(" Id=" + Id);
        }




    }
}
